Algoritmic Images Editor SLANG 2.0 (C) Stepan S. Vartanov, 1995 LICENZE. It is "AS IS". And it is SHAREWARE. If you use Slang without licenze, and find it convenient to use, you should register. Registration fee is 30 $ USA - send check, or money order: P.O.Box 34041 Scotia Square RPO, Halifax, N.S., Canada, B3J 3S1. To receive new versions add registration card in any form. Version 2.0 is SHAREWARE. I used OOPic language interpreter to implement it. This interpreter is more flexible, than real SLANG interpreter, but have few nasty bugs. The v. 3.0 should use real SLANG engine and hopefull, will be bug-free. Registered users of v. 2.0 will have disgrade for next versions (which probably will not be SHAREWARE). WHAT IS SLANG ? Slang is interactive editor of pictures in VEC format. It use formulas to describe the image. All output could be scrolled, zoomed, rotated and printed on different types of printers. Export to BMP (DIB) and WMF format is also supported. Installation. Create the directory (for example, "Slang") and copy the archive to it. Unpack it and then remove the archive. If instead of archivated program, your disk contains non- archivated files, simply copy them to the directory. Do not run SLANG from floppy disk - it is very ineffective. How to work with SLANG. Run SLANG.EXE. There are 4 types of windows in SLANG. Text editor windows let you to edit VEC code. To execute code, choose SLANG/RUN from the menu. Output window work in the DOS-like manner. It show user input and SLANG output performed with PRINT function. If you check the Log file option in OPTIONS/.., this window create the OUTPUT.LOG file and copy all the output there. That is very usefull if you work with some data-processing program operating with the large data blocks. SLANG have other methods for file i/o, but only this way permits you see data in the output window while writing to file. View window shows graphical output of your program. And draw window with tool palette could be used for interactive drawing. SLANG is an VEC language interpreter. *) If you are programmer. SLANG interprete BGI (DOS) or GDI (Windows). It is an exellent tool for maketing the graphic programs (no compiling delay, code and result are visible at the same screen). VEC is a very simple language, it could be studied in a few minutes. Default extention for VEC files is *.VEC. *********************************************** WINDOWS VERSION OF SLANG. Main Menu, File. New Creates new text file. Open Loads program from file (but does not run it before RUN choosed. Save Save program to file. If user choose RUN (draw program in the view panel) the file saving is processed automatically. Save BMP Copy image to BMP file. Be attentive with the zoom of image (see) and with the buffer size. You will be prompted for the image size, in pixels, and for the file name. Print Setup. Set up the printer. Print. Print the image. About Product info dialog. ################################################################## LANGUAGE. You could use examples (*.VEC files) to study VEC. Here are the most important details. Variables in SLANG could be used without declarations. Variable type will be determined using context: x = 2 - type is REAL x = "Hello" - type is STRING The only exeption are arrays. The array should be declared before use: Declaration: ARR[12]; (name ARR, 12 elements, semicolon is necessary in declaration) ... ARR[10] = 321 (usage). Only arrays of REAL are supported. Array elements range is from 1 to n, where n is the number used in declaration. Any attempts to use wrong array indexes are ignored: A[10]; a[5] = 12 ' OK a[50] = 2 ' Ignored __________________________________________________________________________ User-defined functions could not get and return arrays. This situation will be changed in v. 3.0. __________________________________________________________________________ Program consists of the sequence of operators. You can use more than one operator per line, delimiter is ':'. You also can continue the expression on the next line, connector is '\': x = 1: y = 2: print x, y; x = 3 * (2 + 5 * r^2) - \ 12 * k There are two exeptions, array declarations: arr[12]; and labels: #label which should always start from the new line (in the case of array it is not really necessary, but we recommend to do so). __________________________________________________________________________ Functions (use examples). We shell use the following syntax: x = f(x1, s2, ar) - function takes 3 arguments, REAL, STRING and ARRAY and return REAL. __________________________________________________________________________ open(xa, s1) - open the file with file name s, set x1 to the file handle read(handle, buf <, len>) - read from file to the string, len is optional argument - number of bytes to read write(handle, buf <, len>) see read() close(handle) - close the file x = eof(handle) - return 1 if end of file is reached, 0 otherwise x = filelen(handle) - return the length of file seek(handle, offset, fromwhere) - move current position of the file cursor relatively to the file beginning, current position or end (0, 1 or 2) rename(oldname, newname) - rename the file setmode(handle, 1+3+5) set the file access mode. The values of second argument: O_RDONLY 1 O_WRONLY 2 O_RDWR 4 x = getpos(handle) - get current file position remove(filename) - delete file next_line(handle) - skip one line in the file __________________________________________________________________________ gettoken(string, token), tokens_string is delimited with , ;TAB('\9') - parse the string, set string to string without first token, and set token to the first part of string before delimiter x = getreal(string) - get the real from string puttoken(string, token) - append token to the end of string x = strcmp(s1, s2) - string comparison, return -1 if s1 < s2, 0 if s1 equial s2, and 1 if s1 > s2 x = strchr(s1, s2) - scan s1 for the substring s2, return 0 or 1. __________________________________________________________________________ delete(variable name) - remove variable and free memory for i = startvalue to endvalue ... continue - go to the next iteration ... break j - leave cycle of nested cycles, j is the outer cycle variable next if ... then ... else ... endif - if condition is TRUE, the block after then gains the control, else otherwice. @sub(arguments) - all user-defined subroutines have prefix @. It could return value of string or real type. return or return x goto label - pass control to the specified label ... #label - label line should contain only label with the # prefix end - end of the main flow of program or module (file) ' This line is remarked /* This block is remarked */ __________________________________________________________________________ play(file name) - unload current program, load , run it (it should contain "end"-terminated main flow), load calling program and return the control. Functions of calling program are not available, variables are. Recommendation: start your programs with PLAY("RESET.VEC") lplay - the same, but Functions of calling program are available. Memory-consuming. Avoid nested calls! splay - play string instead of file. Example - calculator with the input from the keyboard. __________________________________________________________________________ x = sin(x1) - sinus calculation, all trigon. functions use degrees, not radians. x = cos(x1) x = lg(x1) __________________________________________________________________________ print - output to the "output" window. Argument list should be divided by commas (no effect) or semicolons (new line). Tabulations {tab 3} and formatters {"%f"} could also be used. Examples: print i, j, k, "hello", 3 + x; print i, {tab 5}, {"10.2f"} d; input - user will be prompted to input the data. Format is INPUT argument, type of argument should be known: x = 1 ' x has type REAL input "Input x: ", x This operator contains bugs ! pause x - not implemented, but the word is reserved for use in v. 2.0. __________________________________________________________________________ line(x1, y1, x2, y2) - draw line from (left, top) to (right, bottom) lineto(x1, y1) draw line from the current position to x1, y1 moveto(x1, y1) move the current position to x1, y1 ellipse(xcenter, ycenter, alphastart, alphaend, radius1, radius2) rectangle(x1, y1, x2, y2) poly(num_of_points, x1, y1, ... xn, yn) text(x1, y1, s1) - draw the string using current font textsize(multx, multy, divx, divy) - set font deformation font(s1) set font name (BGI fonts are used) color(x1) - set color using 0 - 15 interval set_rgb(r, g, b) - set color using RGB triplet style(fill_style, fill_color) - set style (pattern) and color for filling fill(x1) - sett fill mode to OFF (0) or ON (1) setline(width, style) - set the line drawing width and style __________________________________________________________________________ The following group of functions affects the image transformations. zoom(x1, y1) - set scaling coefficient for all the following drawing before the next zoom call addzoom(x1, y1) - We use the agreement that zoom could be used in any time, but addzoom - only once, at the beginning of the program. It sets the additional scaling of the whole image. scroll(x1, y1) - scroll the picture addscroll(x1, y1) - additional scrolling, should be called only once mirror(x1) - mirror reflection of the image relatively to the vertical line. Combined with the rotations could produce any reflection. rotate(alpha, x1, y1) - all the following output will be rotated around x1, y1 to alpha SLANG could perform nested rotations. To switch between simple and nested modes use the ROT_ON and ROT_OFF operators, to reduce rotation level, use ENDROTATE: rot_on for i = 0 to 36 rotate(i) line(100, 100, 200, 200) next rot_off __________________________________________________________________________ DIAGRAMMS: get_axes_dim(xmin, ymin, xmax, ymax) - sets arguments to the axes diapazone set_axe - set the axe parameters. 'which, text dir, tick no (-1 for auto), s_tick no<,tick_ar, s_tick_arr> 'if auto (tick_no == -1) then number of sub ticks = s_tick_no * tick no 'in this case tick_no will be 5, sub_tick_no 25 'Manual ticks setup for X: Example: set_axe(1, 1, -1, 5, tar, tar, "One", "Two", "Three", "Four", "Five", "Six") For more examples see graf.vec. axes - draws axes 'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8 Example: axes(YELLOW, LIGHTBLUE, 0, GREEN, 3, 1, 1 + 2) 'axes color, legends color, grid style, grid color, axes width, ticks width, 'axes set (hor1 + vert1) For more examples see graf.vec. cross() - draws 2 lines throught (0,0) calc_scale - set the axe scale ' Given: Array of REAL ............................ xar ' Axe (0 - X, 1 - Y) ...................... axe ' Reset or not previous settings .......... is_first ' Justification method .................... int num_flag 'is_first indicates, is it necessary to use previous scale PLUS new data, ' or only new data. 'num_flag could be -1, 0 and 1. -1 is used for bar graphs to resize axe. ' It is necessary because few bars use additional space - and will not ' fit on graphics otherwise. ' 0 does not produce any action. ' 1 recalculate axe to produce nice-looking labels, Remember that call to ' set_axe() will automatically presume that axes are "nice-looking", ' so you MUST call set_axe() with -1 setting or not to use auto labels. Example: calc_scale(xar, 0, 1, -1, xd) For more examples see graf.vec. get_stacked(xar, zar) - We have 2 arrays, second is the "base", we already have plot it, and first is the array to plot. Type of graf is STACKED BAR GRAF. Call to get_stacked add second array elements to the elements of the first array to produce new base for the next dataset. ' zar[4*i+1] keep ystart < 0; ' zar[4*i+2] keep ystart >= 0; ' zar[4*i+3] keep yend < 0; ' zar[4*i+4] keep yend >= 0; For more examples see graf.vec. grafclip(x1, y1, x2, y2) - set the graf clip rectangle grafscale(x1, y1, x2, y2) - set the graf min and max data values. Used for manual setup - see graf.vec marker_size - size of marker, pixels plot(xarray, yarray, graftype, markertype, shifts) - plot the dataset. Shifts are used for BAR GRAFs, because it could need some extra space. See GRAF.VEC for explanations.